from common.basepage import BasePage
#封装登录页面
class LoginPage(BasePage):
    def __init__(self,driver):
        super().__init__(driver)
        # 页面元素的定位方式
        self.account_loc="id=account"
        self.password_loc="id=password"
        self.submit_loc = "id=submit"
        self.assert_text_loc='css selector=.bootbox-body'

    def type_account(self,name):
        self.input(self.account_loc,name)

    def type_password(self,password):
        self.input(self.password_loc,password)
    def type_submit(self):
        self.button(self.submit_loc)
    
    def assert_text(self):
        return self.get_text(self.assert_text_loc)
        
class MainPage(BasePage):
    def __init__(self, driver):
        super().__init__(driver)
        # 页面元素的定位方式
        # self.account_loc="id=account"
        # self.password_loc="id=password"
        self.submit_loc ='xpath=//*[@id="s-menu-1"]/button'
        self.submit_loc1='xpath=//*[@id="s-menu-superadmin"]/button'
        self.submit_loc2 = 'xpath=//*[@id="bottomRightBar"]/ul/li[1]/a'
        self.assert_text_loc = 'link text=签退'
        
    def kehu_click(self):
        self.button(self.submit_loc)
    def houtai_click(self):
        self.button(self.submit_loc1)
    def qiantui_click(self):
        self.button(self.submit_loc2)
    def assert_text(self):
        return self.get_text(self.assert_text_loc)
        
        
class BackPage(BasePage):
    def __init__(self, driver):
        super().__init__(driver)
        # 切换到外层框架
        self.switch_to_frame("iframe-superadmin")  # 通过id
        self.submit_loc = 'xpath=//*[@id="shortcutBox"]/div/div[1]/div/a'
    def add_click(self):
        self.button(self.submit_loc)
    def backs(self):
        self.switch_to_default_content()